package subumbo.micro.controller
{
	import flash.display.MovieClip;
	import flash.events.Event;

	public class Component extends MovieClip
	{	
		protected var _vo:*;
		private var _centre:EventCentre;
		
		
		public function Component()
		{
			this.addEventListener(Event.ADDED_TO_STAGE, init)
		}
		
		protected function init(e:Event):void
		{
			this.removeEventListener(Event.ADDED_TO_STAGE, init);
			_centre = EventCentre.instance;
			_centre.addEventListener(ApplicationEvent.BIND, bind);
		}
		
		protected function bind(e:ApplicationEvent):void
		{
			_centre.addEventListener(ApplicationEvent.UPDATE, update);
		}
		
		public function update(e:ApplicationEvent):void
		{
			
		}
		
		/**
		 * Dispatches an event to the EventCentre
		 * 
		 * @param event
		 * @return Returns always true.
		 * 
		 */		
		override public function dispatchEvent(event:Event):Boolean
		{
			_centre.dispatch(event);
			return true;
		}
		
		public function addListener(type:String, callback:Function):void
		{
			_centre.addEventListener(type, callback);
		}
		
		public function removeListener(type:String, callback:Function):void
		{
			_centre.removeEventListener(type, callback);
		}
		
		public function get vo():*
		{
			return _vo
		}
	}
}